package com.shumei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shumei.dao.mapper.UInformationMapper;
import com.shumei.dao.pojo.Application;
import com.shumei.dao.pojo.UInformation;
import com.shumei.service.UInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UInformationServiceImpl implements UInformationService {

    @Autowired
    UInformationMapper uInformationMapper;

    public UInformation getdata(Long id){
        QueryWrapper<UInformation> wrapper=new QueryWrapper<UInformation>();
        wrapper.eq("u_id",id);
        UInformation uInformation = uInformationMapper.selectOne(wrapper);
        return uInformation;

    }

    public void  registsetdata(UInformation uInformation){
        int i = uInformationMapper.insert(uInformation);
        if (i>0)
            System.out.println("数据录入成功");
        else
            System.out.println("数据录入失败");
    }

    @Override
    public List<UInformation> selectUInformation() {
        List<UInformation> uInformations=uInformationMapper.selectList(null);

        return uInformations;
    }

    @Override
    public void updateUInformation(UInformation uInformation) {
        QueryWrapper<UInformation> wrapper=new QueryWrapper<UInformation>();
        wrapper.eq("id",uInformation.getId());

        if (uInformationMapper.update(uInformation,wrapper)>0){
            System.out.println("修改成功");
        }
        else {
            System.out.println("修改失败");
        }
    }

    @Override
    public void deleteUInformation(Long id) {
        int i = uInformationMapper.deleteById(id);
        if (i > 0){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
    }
}
